package com.itheima.d3_collection_traverse;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

/**
 *       目标：完成电影信息的展示。
 *       new Movie("《肖生克的救赎》" , 9.7 ,  "罗宾斯")
 *       new Movie("《霸王别姬》" , 9.6 ,  "张国荣、张丰毅")
 *       new Movie("《阿甘正传》" , 9.5 ,  "汤姆.汉克斯")
 */
public class Demo04Practice {
    public static void main(String[] args) {
        // 1、创建一个集合容器负责存储多部电影对象。
        ArrayList<Movie> movies = new ArrayList<>();
        movies.add(new Movie("肖生克的救赎", 9.7, "罗宾斯"));
        movies.add(new Movie("霸王别姬", 9.6, "张国荣、张丰毅"));
        movies.add(new Movie("阿甘正传", 9.7, "汤姆.汉克斯"));
      //  System.out.println("movies = " + movies);

        //for增强遍历
//        for (Movie movie : movies) {
//            System.out.println("movie = " + movie);
//        }
        //迭代器遍历
//        Iterator<Movie> iterator = movies.iterator();
//        while (iterator.hasNext()) {
//            Movie next = iterator.next();
//            System.out.println("next = " + next);
//        }
        movies.forEach(movie -> {System.out.println(movie.getName()+","+movie.getScore()+","+ movie.getActor());});
    }
}
